import type {AxiosInstance} from 'axios'
import axios from 'axios'

interface AxiosTokenInstance extends AxiosInstance {

}

// 创建一个axios实例
const instance: AxiosTokenInstance = axios.create({
    baseURL: '/',
    timeout: 5000,
    responseType: 'json',
    headers: {
        'Content-Type': 'application/json',
    },
})

instance.interceptors.request.use(
    (config) => {
        return config
    },
    (error) => {
        return Promise.reject(error)
    }
)

instance.interceptors.response.use(
    (response)=>{
        return response
    },
    (error)=>{
        return Promise.reject(error)
    }
)

const {request,get,post} = instance;
//暴露axios实例
export {request,get,post,instance};
